if(window.jQuery && window.jQuery.PPF && !window.PPF.shiti_danxuan) {
	(function($){
		var data = { xx : {} };
		var xCount = 0;
		$PPF.extend({
			//to add!
			shiti_danxuan: {
				//检查
				check : function(){
					var _r = $PPF.validate.check( $("[ppf='shiti']") , 3 );
					$("[ppf='shiti']").each(function(){
						data[$(this).attr('name')] = $(this).val();
					});
					var xx = $("input[ppf='xx']");
					var len = xx.length;
					data.xx = {};
					xx.each(		//选项
						function() {
							var v = $(this).val();
							if( v.length > 0 ) {
								data.xx[ $(this).attr('name') ] = $(this).val();
							}else {
								len --;
							}
						}
					);
					if(len < 2) {
						$PPF.validate.tips( 'xx' , "选项数目不够" );
						$("input[ppf='xx']").filter(function(index){
								return !$(this).val();
							}).get(0).focus();
						_r = false;
					}else {
						$PPF.validate.tips( 'xx' );
					}
					data.daan = $("input[name='daan']:checked").val();
					$("input[name='daan']:checked").each(function(){
						if(typeof data.xx[$(this).val()] !== "undefined"){
							data.daan = $(this).val();
						}else {
							try{delete data.daan}catch(e){}
							$(this).removeAttr('checked');
						}
					});
					if( typeof data.daan === "undefined" ){	//答案
						$PPF.validate.tips( 'daan' , "请正确选择答案" );
						$("input[name='daan']:not(:checked)").get(0).focus();
						_r = false;
					}else {
						$PPF.validate.tips( 'daan' );
					}
					return _r;
				},
				//保存
				save: function(url,callback){
					if(this.check()) {
						var query = {};
						query = $PPF.param(data);
						$PPF.tips( {msg: "保存中"} );	//保存中
						if(typeof callback === "undefined") {
							callback = function(data){
								$PPF.tips( {msg: $PPF.jsonmsg(data,"保存成功") , timeout:3000} );
							}
						}
						$.post(url,query,callback,'json');
					}
				},
				addxx: function(  ) {
					if(! xCount ) {
						$("input[ppf='xx']").each(function(){
							if( $(this).attr('name') > xCount ){
								xCount = $(this).attr('name');
							}
						});
					}
					//s = $PPF.content("#xx_tpl");
					s = $("#xx_tpl").content({
						id: ++xCount
					});
					$("div[ppf='add']").before( s );
				},
				delxx: function( i ) {
					if( $("input[ppf='xx']").length <= 2)
						return;
					$("div[ppf='xxc_" + i + "']").remove();
				}
			}
			//to add!
		});
	})(jQuery);
}